package Homework.Homework04;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class RemoveStudent {
    List<Student> list = new ArrayList<>();
    public static void deleteStudent(List<Student> list) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入需要删除的学生学号");
        Integer Id = sc.nextInt();
        int index = -1;
        for (int i = 0; i < list.size(); i++) {
            Student s = list.get(i);
            if (Id.equals(s.getID())) {
                index = i;
            }
            if (index == -1) {
                System.out.println("你要删除的学生不存在，请重新输入");
            } else {
                list.remove(index);
                System.out.println("删除成功！");
            }
        }
    }
}
